﻿using QuickManager.Code.SiteMgr;
using QuickManager.Code.SiteMgr.Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace QuickManager.UI.SiteMgr
{
    public partial class FrmGroupSelect : Form
    {
        public FrmGroupSelect()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (treeView1.SelectedNode != null)
            {
                this.Tag = treeView1.SelectedNode.Tag;
            }
            else
            {
                this.Tag = null;
            }
            this.Close();
        }

        private void FrmGroupSelect_Load(object sender, EventArgs e)
        {
            treeView1.Nodes.Clear();
            foreach (GroupInfoModel group in SiteGroupManager.GetGroupList())
            {
                treeView1.Nodes.Add(new TreeNode()
                {
                    Text = group.GroupName,
                    Tag = group
                });
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Tag = null;
            this.Close();
        }
    }
}
